import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import storage_clear from '@feidao/web/atom/browser/storage/clear';
import user_logout from '@feidao/web/atom/browser/msg/user-logout';
import set_user from '@feidao/web/atom/browser/storage/put';
import { send_msg as url, systemid, get_user_info } from './config';
import whoami from '@feidao/web/atom/browser/msg/whoami';
export default async function a003(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	try {
		const user = await whoami(get_user_info) as {
			usercode: string
		};
		const user_info = await user_logout(url, systemid, user.usercode) as { code: number };
		if (user_info.code === 1) {
			await set_user('user', null);
			await storage_clear('user');
			await storage_clear();
			window.location.href = 'login.html';
		}
	} catch (error) {

		window.location.href = 'login.html';
	}

}
